% TEST_ID: LANG-EXPAND-0057
% CATEGORY: language/function_handle
% 测试函数句柄

function test_function_handle

    f = @f;
    assert(f(1, 2) == 1);

    f = @sin;
    assert(isequal(f(pi/2), sin(pi/2)));

    [h, g] = get_func();
    assert(isequal(h(1), 101));
    assert(isequal(g(1), 201));
end

function r = f(x, y)
    r = x;
end

function [h, g] = get_func()
    function h = f1(x)
        h = x + 100;
    end

    function g = f2(x)
        g = x + 200;
    end
    h = @f1;
    g = @f2;
end